	<!--  以隐藏的方式获取商品的样式 ，作用是样式 -->
	<div id="pelem_goods" style="display:none;">
		<div class="pr" id="elem_goods"><input type="text" class="textbox  customelement" name="good_name"
				autocomplete="off"><span class="ui-icon-ellipsis"></span></div>
	</div>

	<!--  以隐藏的方式获取商品的样式 ，作用是赋值 -->
	<div style="display:none;">
		<input type="text" id="good_name" value="" autocomplete="off" readonly="">
	</div>

	<script type="text/javascript">
	$(document).ready(function () {
		//获取商品
		$(".grid-wrap").on("click", ".ui-icon-ellipsis", function (e) {
			pre_choose_goods('/admin/basic/choose_goods.html', this);

		});
	});
  function pre_choose_goods(url, obj) {
    choose_goods(url, obj, function (res) {
       row_id=parseInt(row_id);
       js_table_data(res,row_id);
    });


  }

  function js_table_data(res,row_id){
     if (res.btn == 3 && res.status == 1) {
        //console.log(res);
        var data = res.data;
        if (data.status == 1) {
          
          var $count=data.info.count;
          var good_list=data.info.list;
          var allIds = $("grid").jqGrid('getDataIDs');
          var ids =  $("#grid").getDataIDs();
          
          // console.log("当前行");
          // console.log(row_id);
          // console.log("长度："+ids.length);
          // console.log(ids);
         
          var $cha_id = ids.length-row_id;//最后id-当前id
          var cha_han= $count-$cha_id-1;//需要补充的行
          //console.log("cha:"+cha_han);
          //补充行
          if(cha_han>0){
                var mydata1 = [];
                for (var iii = ids.length; iii < ids.length+cha_han; iii++) {
                  var obj = { id: iii + 1, good_name: "", goodstype: "", goodsmark: "", dw: "", shuliang: "", ck1: "", ck2: "", ck3: "", mark: "", goodsid: "0", ck1_id: "0", ck2_id: "0" }
                  mydata1.push(obj);
                }
                console.log(mydata1);
                for (var iii = 0; iii <= mydata1.length; iii++) {
                  jQuery("#grid").jqGrid('addRowData', ids.length+iii+1, mydata1[iii]);
                }

          }
          // console.log("1111");
          // return false;

          for (let i = 0; i <$count; i++) {

            $("#grid").jqGrid("saveCell", edit_row, edit_col);
            $("#grid").jqGrid("setCell", row_id+i, 'good_name', good_list[i].name);
            //$("#grid").jqGrid("setCell", row_id+i, 'good_type', good_list[i].goodstype);
            $("#grid").jqGrid("setCell", row_id+i, 'good_mark', good_list[i].mark);
            $("#grid").jqGrid("setCell", row_id+i, 'unit_name', good_list[i].dw);
            $("#grid").jqGrid("setCell", row_id+i, 'good_id', good_list[i].id);
            $("#grid").jqGrid("setCell", row_id+i, 'shuliang', "1");
            $("#grid").jqGrid("setCell", row_id+i, 'base_unit_name', good_list[i].dw);
            $("#grid").jqGrid("setCell", row_id+i, 'base_unit_id', good_list[i].unit_id);
            $("#grid").jqGrid("setCell", row_id+i, 'base_number', "1");
            $("#grid").jqGrid("setCell", row_id+i, 'unit_id', good_list[i].unit_id);
            $("#grid").jqGrid("setCell", row_id+i, 'price', good_list[i].price.estimated_purchase_price);
            //$("#grid").jqGrid("setCell", row_id+i, 'zk_lv', good_list[i].price.discount_rate_one * 100);
            $("#grid").jqGrid("setCell", row_id+i, 'zk_lv', good_list[i].price.discount_rate_one*100);
            //$("#grid").jqGrid("setCell", row_id+i, 'zk_e', good_list[i].price.estimated_purchase_price * good_list[i].price.discount_rate_one);
            $("#grid").jqGrid("setCell", row_id+i, 'zk_e', parseFloat(good_list[i].price.estimated_purchase_price * good_list[i].price.discount_rate_one * 1).toFixed(2));

            $("#grid").jqGrid("setCell", row_id+i, 'hs_price', parseFloat(good_list[i].price.estimated_purchase_price) * parseFloat(good_list[i].tax_rate) + parseFloat(good_list[i].price.estimated_purchase_price));
            //$("#grid").jqGrid("setCell", row_id+i, 'jine', parseInt(good_list[i].price.estimated_purchase_price) * 1 - good_list[i].price.estimated_purchase_price * good_list[i].price.discount_rate_one);
            $("#grid").jqGrid("setCell", row_id + i, 'jine',parseInt(good_list[i].price.estimated_purchase_price) * 1 - good_list[i].price.estimated_purchase_price * good_list[i].price.discount_rate_one);
            var jine = good_list[i].price.estimated_purchase_price * 1 - good_list[i].price.estimated_purchase_price * good_list[i].price.discount_rate_one;
            $("#grid").jqGrid("setCell", row_id+i, 'tax_lv', good_list[i].tax_rate * 100);
            $("#grid").jqGrid("setCell", row_id+i, 'tax_e', parseFloat(jine * good_list[i].tax_rate).toFixed(2));
            var tax_e = parseFloat(jine * good_list[i].tax_rate).toFixed(2);
            $("#grid").jqGrid("setCell", row_id+i, 'total_price', parseFloat(jine / 1 + tax_e / 1).toFixed(2));

            $("#grid").jqGrid("setCell", row_id+i, 'og_id', 0);

          }
          // 计算合计
          var shuliangs = parseFloat($("#grid").getCol('shuliang', false, 'sum')).toFixed(2);
          var base_numbers = parseFloat($("#grid").getCol('base_number', false, 'sum')).toFixed(2);
          var zk_es = parseFloat($("#grid").getCol('zk_e', false, 'sum')).toFixed(2);
          var jines = parseFloat($("#grid").getCol('jine', false, 'sum')).toFixed(2);
          var tax_es = parseFloat($("#grid").getCol('tax_e', false, 'sum')).toFixed(2);
          var total_prices = parseFloat($("#grid").getCol('total_price', false, 'sum')).toFixed(2);
          $("#grid").footerData('set', { "good_name": '合计', shuliang: shuliangs, base_number: base_numbers, zk_e: zk_es, jine: jines, tax_e: tax_es, total_price: total_prices });
          $('#yh_price').val(total_prices);
          $("#before_yh_price").val(total_prices);
          $('#payment').val(total_prices);
          onchange_payment();

        } else {
          layer.msg("获取商品信息失败");
        }
      }

  }
</script>